package com.bases.cellItem
{
	import com.bases.TRadioButton;
	import com.bases.TUIComponent;
	import com.Event.RadioSelectEvent;
	import com.Interface.IItem;
	import com.Interface.ITRadioCellRender;
	
	import flash.events.MouseEvent;
	
	/**
	 *  有关单选的基类(所有的单选都必须继续此类) 
	 * @author pethan
	 * 
	 */	
	public class BaseRadioCellItem extends TUIComponent implements ITRadioCellRender,IItem
	{
		protected var radio:TRadioButton;
		protected var _data:*;
		public function BaseRadioCellItem()
		{
			super();
			this.radio=new TRadioButton();
			this.radio.setPos(2,2);
			this.addChild(this.radio);
			this.addEventListener(MouseEvent.CLICK,onClick);
		}
		
		private function onClick(event:MouseEvent):void{
			if(!this.radio.select){/*当前没有选中的时候,才发事件上去*/
				this.radio.select=true;
				this.dispatchEvent(new RadioSelectEvent(RadioSelectEvent.RADIO_SELECT_EVENT,this,true));
			}
		}
		
		/**
		 * 设置选中 
		 * @param value
		 * 
		 */		
		public function set select(value:Boolean):void{
			this.radio.select=value;
		}
		
		/**
		 * 获取当前是否是选中的状态 true:选中,false为不选中 
		 * @return bool
		 * 
		 */		
		public function get select():Boolean{
			return this.radio.select;
		}
		
		public function set userData(value:*):void{
			_data=value;
		}
		
		public function get userData():*{
			return _data;
		}
	}
}